package com.kkb.service.impl;
import com.kkb.mapper.AccountMapper;
import com.kkb.pojo.Account;
import com.kkb.service.AccountService;
import com.kkb.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service("accountService")
public class AccountServiceImpl implements AccountService {
    @Autowired
    private AccountMapper accountMapper;
    @Override
    public void save(Account account) {
        accountMapper.save(account);
        /* SqlSession sqlSession = MyBatisUtils.getSqlSession();
        AccountMapper mapper = sqlSession.getMapper(AccountMapper.class);
        mapper.save(account);
        sqlSession.commit();
        MyBatisUtils.closeSqlSession(); */
    }

    @Override
    public List<Account> findAll() {
       /* SqlSession sqlSession = MyBatisUtils.getSqlSession();
        AccountMapper mapper = sqlSession.getMapper(AccountMapper.class);
        List<Account> list = mapper.findAll();
        MyBatisUtils.closeSqlSession();
        return list; */
        List<Account> list = accountMapper.findAll();
        return list;
    }
}
